package com.acme.bankapp.service.bank;

import java.util.List;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.client.Client;
import com.acme.bankapp.exceptions.ClientExistsException;

public class BankService {

    private static final String MESSAGE_MAXIMUM_AMOUNT_TO_WITHDRAW = "Maximum amount to withdraw from all accounts:";

    /**
     * Method adds client to bank.
     * @param bank
     * @param client
     * @throws ClientExistsException if client with same name already exists in the bank
     */
    public void addClient(Bank bank, Client client) throws ClientExistsException {
        bank.addClient(client);
    }

    /**
     * Prints maximum amount to withdraw from each of the bank client.
     * @param bank
     */
    public void printMaximumAmountToWithdraw(Bank bank) {
        List<Client> clients = bank.getClients();
        System.out.println(MESSAGE_MAXIMUM_AMOUNT_TO_WITHDRAW);
        for (Client client : clients) {
            System.out.println(client.getAccounts().maximumAmountToWithdraw());
        }
    }
}
